package com.yc.demo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/login.s")
public class LoginServlet extends HttpServlet {
    // doPost => post 请求
    // doGet  => get 请求
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        final String username = req.getParameter("username");
        final String password = req.getParameter("password");
        if ("yc".equals(username) && "123".equals(password)) {
//            登录成功
            // 响应重定向
            resp.sendRedirect("b.html");
        } else {
//            登录失败
            // 响应重定向
            resp.sendRedirect("a.html");
        }

    }
}
